package com.billiards.controller;

import com.billiards.entity.Bulletin;
import com.billiards.entity.User;
import com.billiards.service.BulletinService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class BulletinController {
    @Autowired
    public BulletinService bulletinService;
    @GetMapping("/getBullentin")
    public List<Bulletin> getBullentin(){
        return bulletinService.getBullentin();
    }
    @PostMapping("/addBulletins")
    public int addBulletin(@RequestBody Bulletin bulletin){

        System.out.println("===========");
        System.out.println(bulletin);
        return bulletinService.addBulletin(bulletin);
    }
    @PostMapping("/updateBulletin")
    public int updateBulletin(@RequestBody Bulletin bulletin){

        System.out.println("===========");
        System.out.println(bulletin);
        return bulletinService.updateBulletin(bulletin);
    }
    @GetMapping("/deleteBulletin")
    public int deleteBulletin(int id){
        return bulletinService.deleteBulletin(id);
    }

}
